//
// Created by 86137 on 2024/3/16.
//

#ifndef MYWORK_TASK_BLUETOOTH_H
#define MYWORK_TASK_BLUETOOTH_H

#ifdef __cplusplus
extern "C" {
#endif

#include "drv_dr16.h"
#include "FreeRTOS.h"
#include "bsp_usart.h"
#include "arm_math.h"
#include "math.h"



#define RC_UART_blue huart7
#define BLUE_BUFF_LEN (1)


typedef struct{
    bool is_lost_blue;
    uint8_t raw_blue_data;
    uint8_t blue_data;
    uint8_t last_blue_data;
    UART_HandleTypeDef * _huart;
}rc_blue_t;


void rc_blue_init(rc_blue_t * rc_blue, UART_HandleTypeDef *_huart, pUART_RxEventCallbackTypeDef rc_pCallback);
void blue_update_callback(UART_HandleTypeDef *huart, uint16_t Size);
void blue_unlink_restart(UART_HandleTypeDef *huart);
void blue_start_receive_dma(rc_blue_t * rc_blue);
void blue_data_update(uint8_t blue_data, uint8_t buff);
void blue_update_(rc_blue_t * rc_blue, uint8_t *buff);
bool blue_update(rc_blue_t * rc_blue);
void set_blue_connect(rc_blue_t * rc_blue);
void set_blue_lost(rc_blue_t * rc_blue);

void blueToothTask(void *argument);






#ifdef __cplusplus
}
#endif

#endif //MYWORK_TASK_BLUETOOTH_H
